<template>
  <div style="height: 100%">
    <el-table
        :data="yhList"
        height="100%"
        stripe
        style="width: 100%">
      <el-table-column
          label="序号"
          type="index"
          width="50">
      </el-table-column>
      <el-table-column
          label="名称"
          prop="mc"
          width="235px">
      </el-table-column>
      <el-table-column
          label="登陆别名"
          prop="dlbm"
          show-overflow-tooltip>
      </el-table-column>
      <el-table-column
          label="创建时间"
          prop="cjsj"
          sortable
          width="180">
      </el-table-column>
      <el-table-column
          label="操作"
          width="125px">
        <template slot-scope="{row}">
          <el-link type="warning" @click="resetPassword(row)">重置密码</el-link>
          <el-link v-show="row.sfsc==='N'" style="margin-left: 15px" type="danger"
                   @click="preDel(deleteYh,row,`即将删除【${row.mc}】,删除后不可恢复，是否继续？`)">删除
          </el-link>
          <el-link v-show="row.sfsc==='Y'" style="margin-left: 15px" type="primary" @click="undeleteYh(row)">恢复
          </el-link>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import commonMixins from "@/mixins/commonMixins";
import md5 from 'md5'

export default {
  mixins: [commonMixins],
  name: "Yhgl",
  data () {
    return {
      yhList: []
    }
  },
  mounted () {
    this.queryYhList()
  },
  methods: {
    async queryYhList () {
      this.yhList = await this.$api.queryYhList({})
    },
    async deleteYh (yh) {
      await this.$api.deleteYh({ rybm: yh.rybm })
      this.queryYhList()
    },
    async undeleteYh (yh) {
      await this.$api.undeleteYh({ rybm: yh.rybm })
      this.queryYhList()
    },
    async resetPassword (yh) {
      await this.$api.setPassword({ rybm: yh.rybm, kl: md5("11111111") })
    }
  }
}
</script>

<style scoped>

</style>
